package bh

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import yyee.llee.mmee.common.R
import yyee.llee.mmee.common.databinding.ActivityXieyisetBinding

class DD : AppCompatActivity() {

    var bidingF: ActivityXieyisetBinding? = null
    val binding get() = bidingF!!
    var mFragments: ArrayList<Fragment> = ArrayList()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        bidingF = ActivityXieyisetBinding.inflate(layoutInflater)
        setContentView(binding.root)
        showFragment(GB())
    }

    private fun showFragment(fragment: Fragment) {
        hiddenFragments()
        val fragmentTransaction = supportFragmentManager.beginTransaction();
        if (fragment != null && mFragments.contains(fragment)) {
            fragmentTransaction.show(fragment)
        } else {
            if (fragment != null && !fragment.isAdded) {
                fragmentTransaction.add(R.id.fl, fragment)
            }
        }
        fragmentTransaction.commitNowAllowingStateLoss()
    }

    private fun hiddenFragments() {
        if (mFragments.size > 0) {
            for (fragment in mFragments) {
                val fragmentTransient = supportFragmentManager.beginTransaction()
                fragmentTransient.hide(fragment)
                fragmentTransient.commitNowAllowingStateLoss()
            }
        }
    }
}